<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="/js/rem.js" type="text/javascript"></script>
    <title></title>
    <link rel="stylesheet" href="/css/common.css" type="text/css">
    <link rel="stylesheet" href="/css/sign-up.css" type="text/css">
    <link rel="stylesheet" href="/css/active.css" type="text/css">
    <link rel="stylesheet" href="/css/activity_index.css" type="text/css">
    <link rel="stylesheet" href="/css/index.css?v=2.0" type="text/css">
    <link rel="stylesheet" href="/css/register_info.css" type="text/css">
    <link rel="stylesheet" href="/css/guide.css" type="text/css">
    <link rel="stylesheet" href="/css/weui.min.css" type="text/css"/>
    <script th:if="${activity_id}!=null" th:inline="javascript">
        var activity = {
            activity_id: [[${activity_id}]]
        }
        window.localStorage.setItem("activity", JSON.stringify(activity));
    </script>
</head>
<body>
<!-- 活动首页 -->
<div class="page has-clear" id="activity_main">
    <div id="pic" class="top">
        <a href="javascript:showDialog_ActivityPrizeRule()" class="prizerules">获奖规则&nbsp;&gt;</a>
        <a href="javascript:showDialog_ActivityPrizedetail()" class="prizedetail">奖项信息&nbsp;&gt;</a>
        <a href="javascript:showDialog_ActivityTime()" class="activitytime">活动时间&nbsp;&gt;</a>
        <a href="javascript:showWinners()" class="regs" th:if="${winners}==1">获奖名单&nbsp;&gt;</a>
    </div>
    <div class="signup_container">
        <div class="container_top">

            <ul class="act_user_info">

            </ul>

            <div class="progressbar1">
                <span class="activity_state"
                      style="font-size: 0.8rem;margin-bottom: 0.3rem;display: block;color: #5bd9ee;">

                </span>
                <div class="progressbar_back">

                    <div class="progressbar_front"></div>
                </div>
                <p class="time_remaing"></p>
            </div>
        </div>
        <div class="container_center">

            <div style="text-align: center; margin-bottom: 2rem;margin-top: 2rem;">
                <a class="signup1 iwannaregiste ">上传作品</a>
                <a class="voteup iwannavote" th:if="${activity.getIS_ROTE()==0}">我要投票</a>

            </div>
            <div class="content1">
                <p class="title">活动详情</p>
                <div id="activity_details" class="prize_rule">

                </div>
            </div>
        </div>
        <div class="container_content">
            <ul class="works works_list">

            </ul>
        </div>
    </div>
</div>
<input type="hidden" th:value="${winners}" id="winner">

<!-- 活动主页 投稿作品 -->
<script type="text/html" id="tpl_works_item">
    <li class="clik_like">
        <input type="hidden" value="[work_id]">
        <div class="clik_like_img"><img src="/img/4-2.jpg"><span class="vote_num">[votes_number]票</span></div>
        <div class="clik_like_content">
            <h4>[work_name]</h4>
            <p>作者：[user_name]</p>
            <p>[district_name]</p>
            <a onclick="voteIt(this)" class="like1"><img src="/img/heart_unselected.png">&nbsp;&nbsp;为Ta点赞</a>
        </div>
    </li>
</script>
<!--用户参与信息-->
<script type="text/html" id="tpl_act_user_info_content">
    <li>[workusernum]<br>已报名</li>
    <li th:if="${activity.getIS_ROTE()==0}">[votes_number]<br>累积投票</li>
    <li>[activity_visist]<br>访问量</li>
</script>
<!--剩余时间-->
<script type="text/html" id="tpl_time_remaining">
    活动剩余：<span class="red">[day]</span>天<span class="red">[hour]</span>小时<span class="red">[minute]</span>分钟<span
            class="red">[second]</span>秒
</script>

<!--活动说明 -->

<div id="activity_instruction" class="registration_win window_parent activity_instruction">
    <div class="active_reg">
        <span>活动规则</span>
        <img src="/img/activity_close.png" onclick="closeDialog(this)" class="act_close">
        <div id="detail_content" class="detail_content">
            <p>
            </p>
        </div>
    </div>
</div>

<div id="prize_instruction" class="registration_win window_parent activity_instruction">
    <div class="active_reg">
        <span>奖项信息</span>
        <img src="/img/activity_close.png" onclick="closePrize(this)" class="act_close">
        <div id="prize_content" class="detail_content">

        </div>
    </div>
</div>

<div id="prizeWork_instruction" class="registration_win window_parent activity_instruction">
    <div class="active_reg">
        <span>获奖名单</span>
        <img src="/img/activity_close.png" onclick="closePrize(this)" class="act_close">
        <div id="prizeWork_content" class="detail_content">



        </div>
    </div>
</div>


<div id="time_instruction" class="registration_win window_parent activity_instruction">
    <div class="active_reg">
        <span>活动时间</span>
        <img src="/img/activity_close.png" onclick="closePrize(this)" class="act_close">
        <div id="time_content" class="detail_content">
            <span th:if="${activity.STAGE_IS_OPEN}==0" >决赛</span>
            <p th:if="${activity.STAGE_IS_OPEN}==0" th:text="'开始：'+${activity.STARTTIME}"></p>
            <p th:if="${activity.STAGE_IS_OPEN}==0" th:text="'结束：'+${activity.ENDTIME}"></p>


            <span th:if="${activity.STAGE_1ST_NAME!=null}" th:text="${activity.STAGE_1ST_NAME}"></span>
            <p th:if="${activity.STAGE_1ST_NAME!=null}" th:text="'开始：'+${activity.ST1_STARTTIME}"></p>
            <p th:if="${activity.STAGE_1ST_NAME!=null}" th:text="'结束：'+${activity.ST1_ENDTIME}"></p>

            <span th:if="${activity.STAGE_2ND_NAME!=null}" th:text="${activity.STAGE_2ND_NAME}"></span>
            <p th:if="${activity.STAGE_2ND_NAME!=null}" th:text="'开始：'+${activity.ST2_STARTTIME}"></p>
            <p th:if="${activity.STAGE_2ND_NAME!=null}" th:text="'结束：'+${activity.ST2_ENDTIME}"></p>

            <span th:if="${activity.STAGE_3RD_NAME!=null}" th:text="${activity.STAGE_3RD_NAME}"></span>
            <p th:if="${activity.STAGE_3RD_NAME!=null}" th:text="'开始：'+${activity.ST3_STARTTIME}"></p>
            <p th:if="${activity.STAGE_3RD_NAME!=null}" th:text="'结束：'+${activity.ST3_ENDTIME}"></p>

            <span th:if="${activity.STAGE_4TH_NAME!=null}" th:text="${activity.STAGE_4TH_NAME}"></span>
            <p th:if="${activity.STAGE_4TH_NAME!=null}" th:text="'开始：'+${activity.ST4_STARTTIME}"></p>
            <p th:if="${activity.STAGE_4TH_NAME!=null}" th:text="'结束：'+${activity.ST4_ENDTIME}"></p>
        </div>
    </div>
</div>
<input type="hidden" id="admin" th:value="${admin}"/>
<!-- 排行榜 tab  切换活动后进行清空操作 添加标记  has-clear 为清空标记  此模块下 votes_rule  order_work_list为 需要更换的内容 _-->
<div class=" page has-clear" id="order_main">
    <div class="top">
        <div class="all_search">
        <input type="text" placeholder="点击搜索" class="all_search_input">
        <div class="show_search">
            <input type="hidden" id="search_content">
            <input class="search_input"  type="text" id="search_box" placeholder="请输入作品名称"/>
            <input  type="hidden" id="search_user_name">
            <input  class="search_input" type="text" id="search_name" placeholder="请输入作者名字"/>
            <input type="hidden" id="search_work_id">
            <input  class="search_input" type="text" id="search_id" placeholder="请输入作品编号"/>

            <input id="district_id" name="district_id" type="hidden">
            <input class="search_input" id="district_name" name="district_name" readonly
                   type="text"
                   placeholder="请选择推荐单位">

            <!--<a onclick="searchWorks(this);" class="search"><img src="/img/search.png"></a>-->
            <div class="all_btn">
                <button class="refu" onclick="refu(this);">重置</button>
                <button class="cancel">取消</button>
                <button class="search_btn" onclick="searchWorks(this);">搜索</button>
            </div>

        </div>
            <div class="bg"></div>
        </div>
        <div  th:if="${activity.getIS_ROTE()==0}"><span class="votes_rule"></span>
        </div>
    </div>
    <div class="content">
        <div class="order_work_list">

        </div>
        <div class="hide">

        </div>
    </div>
</div>
<script type="text/plain" id="tpl_order_work_votes_rule">
    每人每天[votes_limit_perday]票，每个选手[votes_limit_tosingle_perday]票!


</script>
<script type="text/html" id="tpl_order_work_item">
    <li class="content_nav">
        <input type="hidden" name="work_id" value="[work_id]">
        <h4>[no]</h4>
        <div class="content_img"><img src="[work_imgurl]" class="image1"></div>
        <div class="content_reg">
            <p style="text-overflow: ellipsis;overflow: hidden;white-space: nowrap;width:9rem">[work_name]</p>
            <span>作者：[user_name]</span><br>
            <span style="text-overflow: ellipsis;overflow: hidden;white-space: nowrap;width:8rem;display: block">[district_name]</span>
            <span>作品编号：[work_id]</span>
        </div>
        <div class="content_vote"  th:if="${activity.getIS_ROTE()==0}">
            <p><span>[votes_number]</span>票</p>
            <a onclick="voteIt(this);">为Ta点赞</a>
        </div>
        <div class="clear"></div>
    </li>
</script>
<script type="text/html" id="tpl_order_work_item1">
    <p>sadifhidijuu</p>
    <p style="    margin: 0 auto 1rem;width: 50%" >暂无获奖规则</p>
</script>


<script type="text/html" id="prize_item">
    <span>[prize_name]</span>
    <img src="[prize_goods_img]" style="display: block; color: gray; width: 10rem; font-size: 1.3rem; text-align: center; height: 6rem;line-height: 3rem; margin: 0 auto 1rem;">
    <p>奖品：[prize_goods]</p>
    <p>数量：[prize_usernumber]</p>
</script>



<script type="text/html" id="prize_item1">
    <p style="    margin: 0 auto 1rem;width: 50%" >暂无奖项信息</p>
</script>



<script type="text/html" id="prizeWork_item">
    <div>
        <img src="[work_imgurl]" style="display: block; color: gray; width: 10rem; font-size: 1.3rem; text-align: center; height: 6rem;line-height: 3rem; margin: 0 auto 1rem;">
        <p >作者：[user_name]</p>
        <p >作品：[work_name]</p>
    </div>
</script>

<script type="text/html" id="prizeWork_item1">
    <p style="margin: 0 auto 1rem; width: 50%;">暂无获奖者</p>
</script>















<!--修改报名信息 和 作品信息 -->
<!--报名信息 tab -->
<div class="page has-clear" id="register_main">

</div>
<script type="text/html" id="state_no_all_info">
    <div class="state nosignup">
        <p>暂无报名信息</p>
        <a href="javascript:gotoRegister(0);" class="click_signup">点击报名</a>
    </div>
</script>
<script type="text/html" id="state_no_all_infono">
        <div class="state nosignup">
            <p>暂无报名信息</p>
            <P>报名已结束</P>
        </div>
</script>
<script type="text/html" id="state_no_work_info">
    <div class="state sign_up_details">
        <p>报名信息</p><a href="javascript:editRegInfo(1)" style="margin-right: 1rem" class="edit_details">修改</a>
        <div class="sign_up_item">
            <div>
                <label>真实姓名:</label>
                <input type="text" value="[user_name]" name="user_name"/>
            </div>
            <div>
                <label>年龄:</label>
                <input type="number" value="[age]" name="age"/>
            </div>
            <div>
                <label>推荐单位:</label>
                <input name="district_name" value="[district_name]" readonly type="text">
                <input type="hidden" name="district_id" value="[district_id]">
            </div>
            <div>
                <label>手机号码:</label>
                <input name="telephone" value="[telephone]" type="tel" pattern=""/>
            </div>
        </div>
        <div class="works_details">
            <p>暂无作品信息</p>
            <a href="javascript:addworks();" class="add_works">点击添加作品</a>
        </div>
    </div>
</script>
<script type="text/html" id="state_no_work_infono">
    <div class="state sign_up_details">
        <p>报名信息</p><!--<a href="javascript:editRegInfo(1)" style="margin-right: 1rem" class="edit_details">修改</a>-->
        <div class="sign_up_item">
            <div>
                <label>真实姓名:</label>
                <input type="text" value="[user_name]" name="user_name"/>
            </div>
            <div>
                <label>年龄:</label>
                <input type="number" value="[age]" name="age"/>
            </div>
            <div>
                <label>推荐单位:</label>
                <input name="district_name" value="[district_name]" readonly type="text">
                <input type="hidden" name="district_id" value="[district_id]">
            </div>
            <div>
                <label>手机号码:</label>
                <input name="telephone" value="[telephone]" type="tel" pattern=""/>
            </div>
        </div>
        <div class="works_details">
            <p>暂无作品信息</p>
            <!--<a href="javascript:addworks();" class="add_works">点击添加作品</a>-->
        </div>
    </div>
</script>
<script type="text/html" id="state_all_info">
    <div class="details">
        <p>报名信息</p><a href="javascript:editRegInfo();" style="margin-right: 1rem" class="edit_details">修改</a>
        <div class="details_item">
            <div>
                <label>真实姓名:</label>
                <input type="text" value="[user_name]" name="user_name"/>
            </div>
            <div>
                <label>年龄:</label>
                <input type="number" value="[age]" name="age"/>
            </div>
            <div>
                <label>推荐单位:</label>
                <input name="district_name" value="[district_name]" readonly type="text">
                <input type="hidden" name="district_id" value="[district_id]">
            </div>
            <div>
                <label>手机号码:</label>
                <input name="telephone" value="[telephone]" type="tel" pattern=""/>
            </div>
        </div>
        <div class="works_content">

        </div>
        <div class="works_details_2">
            <a href="javascript:addworks();" class="add_works">点击添加作品</a>
        </div>
    </div>
</script>
<script type="text/html" id="state_all_infono">
    <div class="details">
        <div class="details_item">
            <div>
                <label>真实姓名:</label>
                <input type="text" value="[user_name]" name="user_name"/>
            </div>
            <div>
                <label>年龄:</label>
                <input type="number" value="[age]" name="age"/>
            </div>
            <div>
                <label>推荐单位:</label>
                <input name="district_name" value="[district_name]" readonly type="text">
                <input type="hidden" name="district_id" value="[district_id]">
            </div>
            <div>
                <label>手机号码:</label>
                <input name="telephone" value="[telephone]" type="tel" pattern=""/>
            </div>
        </div>
        <div class="works_content">

        </div>

    </div>
</script>
<div class="add_works_alert" onclick="closemyself(this);">
    <div class="add_works_item">

        <a class="video_works work_type a">视频作品</a>
        <a class="audio_works work_type b">音频作品</a>
        <a class="read_works work_type c">范文朗读</a>
        <a class="picture_works work_type d">图片作品</a>
    </div>
</div>
<div class="edit_works_alert" onclick="closemyself(this);">
    <div class="edit_works_item">
        <a class="video_works edit">编辑</a><br>
        <a class="audio_works del">删除</a>
    </div>
</div>
<!-- 奖项 -->
<div class="page has-clear" id="prize_main">

    <div class="content">

        <div class="head">
            <img src="/img/guide_title.png" alt="">
            <h1>操作流程</h1>
        </div>
        <div class="one">
            <h2>第一步：关注</h2>
            <p th:text="'关注【'+${logo.getWX_COUNT()}+'】'">关注【重庆市儿童图书馆公众号】</p>
            <img src="/img/mp_qrcode.png" th:src="${logo.getWX_IMG()}" alt="" style="width: 220px;height: 220px">
        </div>
        <div class="two">
            <h2>第二步：报名</h2>
            <p>进入微信活动首页，选择相应的活动，参与报名！</p>
            <img src="/img/2-1.png" alt="">
            <img src="/img/2-2.png" alt="">
        </div>
        <div class="three">
            <h2>第三步：上传活动作品</h2>
            <p>进入报名页面，填写报名信息，上传报名作品及封面。</p>
            <img src="/img/3-1.png" alt="">
            <img src="/img/3-2.png" alt="">
        </div>
        <div class="four"  th:if="${activity.getIS_ROTE()==0}">
            <h2>第四步：分享集赞</h2>
            <p>报名成功后，可以对活动页面分享，集赞。</p>
            <img src="/img/4-1.png" alt="">
            <img src="/img/4-2.png" alt="">
        </div>
        <div class="five" th:if="${activity.getIS_ROTE()==0}">
            <h2>第五步：等待评奖</h2>
            <p>等待评奖</p>
        </div>
        <div class="five" th:if="${activity.getIS_ROTE()==1}">
            <h2>第四步：等待评奖</h2>
            <p>等待评奖</p>
        </div>

    </div>

</div>
<!--奖项设置项 -->
<script type="text/html" id="tpl_prize_item">
    <li>
        <div class="prize_system"><h5>[prize_usernumber]名</h5>
            <div><img src="[prize_goods_img]"></div>
        </div>
        <div class="list_item_[rank]">[prize_name]</div>
    </li>
</script>
<div id="footer">
    <ul>
        <li class="active"><a data-page_id="1"><img data-normal_url="/img/bottom_home.png"
                                                    data-selected_url="/img/bottom_home_selected.png"
                                                    src="/img/bottom_home.png" id="bottom_home"> <br> <span>首页</span>
        </a>
        </li>
        <li><a data-page_id="2"><img data-normal_url="/img/bottom_order.png"
                                     data-selected_url="/img/bottom_order_selected.png" src="/img/bottom_order.png">
            <br><span>排行 </span> </a></li>
        <li><a data-page_id="3"><img data-normal_url="/img/bottom_signup.png"
                                     data-selected_url="/img/bottom_signup_selected.png" src="/img/bottom_signup.png">
            <br><span>报名</span>
        </a></li>
        <li><a data-page_id="4"><img data-normal_url="/img/guide.png"
                                     data-selected_url="/img/guide_selected.png"
                                     src="/img/guide.png"><br><span>指南</span> </a></li>
    </ul>
</div>
<!--活动列表-->
<div id="act_list_main" class="active">
    <ul class="content_activity">
    </ul>
    <div class="hide">

    </div>
</div>
<!-- 活动列表单项 -->
<script type="text/html" id="tpl_activity_item">
    <li class="content_activity_item">
        <div class="content_activity_top">
            <img src="[activity_img]">
        </div>
        <div class="content_activity_content">
            <p>[activity_name]</p>
            <p ><img src="/img/yonghu.png"/> [authernumber]人投票，已投[votes_number]票[activity_state]</p>
            <div class="activity_stage_info">
            </div>

        </div>
        <input type="hidden" value="[activity_id]" class="act_id">
        <input type="hidden" value="[is_in]" class="is_in">
    </li>
</script>
<script type="text/html" id="tpl_activity_items">
    <li class="content_activity_item">
        <div class="content_activity_top">
            <img src="[activity_img]">
        </div>
        <div class="content_activity_content">
            <p>[activity_name]</p>
            <p><img src=""/> [activity_state]</p>
            <div class="activity_stage_info">
            </div>

        </div>
        <input type="hidden" value="[activity_id]" class="act_id">
        <input type="hidden" value="[is_in]" class="is_in">
    </li>
</script>
<script type="text/html" id="tpl_activity_stage_item">
    <p class="match">[stage_name]：[stage_start_time] -- [stage_end_time]</p>
</script>
<!-- 更多活动按钮 -->
<img id="more_act" src="/img/more_act.png">
<!-- 从活动页面返回 -->
<img id="more_act_hide" style="display:none;" src="/img/more_act_hide.png">
<!-- 用户作品列表条目 音频 -->
<script type="text/html" id="my_work_item_a">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:editworks([work_id],[work_type]);" class="edit_details">修改</a>
        <br/>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="audio_button">
                    <div class="audio_img">
                        <button type="button" onclick="pauseAudio(this)" class="play"></button>
                    </div>
                    <audio src="[resource_url]" controls="" ></audio>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_ano">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:PrizeLook([work_id]);" class="edit_details">获奖情况</a>
        <br/>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="audio_button">
                    <div class="audio_img">
                        <button type="button" onclick="pauseAudio(this)" class="play"></button>
                    </div>
                    <audio src="[resource_url]" controls="" ></audio>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_anoy">
    <div class="my_work_item">
        <p>作品信息</p>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="audio_button">
                    <div class="audio_img">
                        <button type="button" onclick="pauseAudio(this)" class="play"></button>
                    </div>
                    <audio src="[resource_url]" controls="" ></audio>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<!-- 用户作品列表条目 视频 -->
<script type="text/html" id="my_work_item_v">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:editworks([work_id],[work_type]);" class="edit_details">修改</a>
        <br>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="video_button">
                    <video src="[resource_url]" controls="controls"></video>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_vno">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:PrizeLook([work_id]);" class="edit_details">获奖情况</a>
        <br>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="video_button">
                    <video src="[resource_url]" controls="controls"></video>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_vnoy">
    <div class="my_work_item">
        <p>作品信息</p>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品:</label>
                <div class="video_button">
                    <video src="[resource_url]" controls="controls"></video>
                </div>
                <input type="hidden" value="[resource_url]" name="resource_url"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_p">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:editworks([work_id],[work_type]);" class="edit_details">修改</a>
        <br/>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_pno">
    <div class="my_work_item">
        <p>作品信息</p><a href="javascript:PrizeLook([work_id]);" class="edit_details">获奖情况</a>
        <br/>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<script type="text/html" id="my_work_item_pnoy">
    <div class="my_work_item">
        <p>作品信息</p>
        <br/>
        <a href="javascript:PicLook([work_id]);" style="color: #2e94d2; position: absolute; right: 0rem; top: 3.5rem; border-bottom: 1px solid #2e94d2;">查看作品详情</a>
        <div class="works_item">
            <div>
                <label>作品名称:</label>
                <input type="text" readonly value="[work_name]" name="work_name"/>
            </div>
            <div>
                <label>作品封面:</label>
                <div class="works_img">
                    <img src="[work_imgurl]">
                </div>
                <input type="hidden" value="[work_imgurl]" name="work_imgurl"/>
            </div>
            <div>
                <label>作品描述:</label>
                <div>
                    <span>[work_assessment]</span>
                </div>
            </div>
        </div>
    </div>
</script>
<div style="display: none;" id="district_list">
    <span class="district_item" >
        <span>0</span>
        <span>请选择推荐单位</span>
    </span>

    <span class="district_item" th:each="dis:${dis}">
        <span th:text="${dis.ID}"></span>
        <span th:text="${dis.DISTRICT_NAME}"></span>
    </span>
</div>
<script type="text/javascript" src="/js/zepto.js"></script>
<script type="text/javascript" src="/js/touch.js"></script>
<script type="text/javascript" src="/js/util.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.2.1/weui.min.js"></script>
<script>
    window.addEventListener("pageshow", function(){
        if(sessionStorage.getItem("need_refresh")){
            location.reload();
            sessionStorage.removeItem("need_refresh");

        }

    });
    //console.log("last_index:",window.localStorage.getItem("last_index"));
    $(function () {

        //TODO：地区选择
        var district_list = [];
        $("#district_list").children(".district_item").each(function (idx, item) {

            district_list.push({
                label: $(item).children("span:last-child").html(),
                value: $(item).children("span:first-child").html()
            })
        });

        $("#district_name").on("click", function (evt) {

            weui.picker(district_list,
                {
                    onChange: function (result) {
                        //console.log("change:",result);

                    },
                    onConfirm: function (result) {
                        var ret = result[0];
                        $("#district_name").val(ret.label);
                        $("#district_id").val(ret.value);
                    },
                    title: '选择推荐单位'
                })

        })

    });

    function isLogin(){
        if (!window.localStorage.getItem("user_info") || JSON.parse(window.localStorage.getItem("user_info")).user_id == ""||JSON.parse(window.localStorage.getItem("user_info")).user_id == null) {
            // console.log()
            //调用 微信用户授权接口
            window.WechatAuthToGetUserInfo();

            //alert("当前操作需要获取您的微信信息！")
            //获取完成后 保存起来
            return false;
        }
        return true;
    }
    function voteIt(a) {

        if(!isLogin())return;


        var is_Vote = JSON.parse(window.localStorage.getItem("activity")).is_vote
        if(is_Vote==0){
            alert("投票未开始！");
            return;
        }
        if(is_Vote==2){
            alert("投票已结束！");
            return;
        }
        $.ajax({
            url: "/front/vote",//TODO： 投票 接口  作品ID 以及用户ID
            data: {
                work_id: $(a).parent().siblings("input").val()
                , user_id: JSON.parse(window.localStorage.getItem("user_info")).user_id,
                activity_id: JSON.parse(window.localStorage.getItem("activity")).activity_id
            },
            async: false,
            dataType: "json",
            success: function (res) {
                if (res.code == 1) {
                    $(a).prev("p").find("span").html(parseInt($(a).prev("p").find("span").html())+1);
                    alert(res.msg)
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                // console.log(res)
                alert("正在加载···")

            }
        })

        return false;


    }

    /*========================================================================================================*/
    function addworks() {
        var activity=JSON.parse(window.localStorage.getItem("activity"));
        //console.log(activity.work_type);
        var nums=[1,2,4,8];
        var clas=["a","b","c","d"]


        $(".add_works_alert .work_type").each(function(index,it){
            $(this).css("display","none");

        })
        $.each(nums,function(idx,item){
            var work_type=parseInt(activity.work_type);
            if((work_type&item)==item){
                $(".add_works_alert ."+clas[idx]).css("display","block");
            }
        })

        $(".add_works_alert").css("display", "block");
        //添加作品的弹窗
        //添加还是删除
        $(".add_works_alert").find(".video_works")[0].onclick = function () {
            if(!isLogin())return;
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;

            window.location.href = "/front/videoWorkUpload?user_id=" + user_id + "&activity_id=" + activity_id
        }
        $(".add_works_alert").find(".audio_works")[0].onclick = function () {
            if(!isLogin())return;
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
            window.location.href = "/front/audioWorkUpload?user_id=" + user_id + "&activity_id=" + activity_id
        }
        $(".add_works_alert").find(".read_works")[0].onclick = function () {
            if(!isLogin())return;
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
            window.location.href = "/front/readWork?user_id=" + user_id + "&activity_id=" + activity_id
        }
        $(".add_works_alert").find(".picture_works")[0].onclick = function () {
            if(!isLogin())return;
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
            window.location.href = "/front/pictureWork?user_id=" + user_id + "&activity_id=" + activity_id
        }

    }

    function PicLook(work_id) {
        window.location.href =  "/front/showWork?work_id=" + work_id;//"/front/PicLook?work_id=" + work_id;
    }

    function editworks(work_id, work_type) {
        //TODO 编辑 作品信息的弹窗
        $(".edit_works_alert").css("display", "block")
        //编辑还是删除
        $(".edit_works_alert").find(".edit")[0].onclick = function () {
            if(!isLogin())return;

            //添加报名信息
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
            if (work_type == 0)
                window.location.href = "/front/videoWorkUpload?user_id=" + user_id + "&activity_id=" + activity_id + "&work_id=" + work_id
            else if(work_type == 1)
                window.location.href = "/front/audioWorkUpload?user_id=" + user_id + "&activity_id=" + activity_id + "&work_id=" + work_id
            else if(work_type == 2)
                window.location.href = "/front/pictureWork?user_id=" + user_id + "&activity_id=" + activity_id + "&work_id=" + work_id
        }
        $(".edit_works_alert").find(".del")[0].onclick = function () {
            if(!isLogin())return;

            if (confirm("确定要删除该作品吗？")) {
                $.ajax({
                    url: "/front/delWork",
                    method: "get",
                    async: false,
                    data: {
                        work_id: work_id
                    },
                    success: function (res) {
                        if (res > 0) {
                            window.clearPage(3);
                            window.switchToPage(3);
                        } else {
                            alert("服务器返回了错误的结果！")
                        }
                    },
                    error: function (res) {
                        alert("正在加载···")

                    }
                })
            }
        }
    }

    function PrizeLook(work_id){
        var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
        window.location.href="/front/PrizeLook?WORK_ID="+work_id+"&ACTIVITY_ID="+activity_id
    }

    function editRegInfo() {
        if(!isLogin())return;

        //TODO 编辑 注册信息 的弹窗
        $(".edit_works_alert").css("display", "block")
        //编辑还是删除
        $(".edit_works_alert").find(".edit")[0].onclick = function () {
            //添加报名信息
            var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
            var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
            var admin = $("#admin").val();
            console.log("admin是>>>>>",admin)
            window.location.href = "/front/register?user_id=" + user_id + "&activity_id=" + activity_id + "&is_edit=1&admin="+admin
        }
        $(".edit_works_alert").find(".del")[0].onclick = function () {
            if (confirm("删除报名信息同时，作品将一并删除，确定要这样操作吗？")) {
                var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
                var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
                $.ajax({
                    url: "/front/delUserRegInfo",
                    method: "get",
                    async: false,
                    data: {
                        user_id: user_id,
                        activity_id: activity_id
                    },
                    success: function (res) {
                        if (res > 0) {
                            window.clearPage(3);
                            window.switchToPage(3);
                        } else {
                            alert("服务器返回了错误的结果！")
                        }
                    },
                    error: function (res) {
                        alert("正在加载···")
                    }
                })
            }
        }
    }

    function closemyself(div) {
        $(div).css("display", "none");
    }

    function gotoRegister() {
        //type 0 添加  1 编辑
        if(!isLogin())return;
        var admin = $("#admin").val();
        //添加报名信息
        var user_id = JSON.parse(window.localStorage.getItem("user_info")).user_id;
        var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
        window.location.href = "/front/register?user_id=" + user_id + "&activity_id=" + activity_id + "&is_edit=0&admin="+admin
    }

    function pauseAudio(btn) {
        //分清 jquery 对象 和 dom对象
        var audio = $(btn).parent().siblings("audio")[0];

        if (audio.paused) {
            audio.play();
        } else {
            audio.pause();

        }
    }

    window.tplReg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm'); //i g m是指分别用于指定区分大小写的匹配、全局匹配和多行匹配。

    function searchWorks(btn) {
        //清空作品
        $("#order_main").find(".order_work_list").empty();
        //作品名称
        $("#search_content").val($("#search_box").val());
        //作品编号
        $("#search_user_name").val($("#search_name").val());
        //作者名字
        $("#search_work_id").val($("#search_id").val());

        $(".show_search,.bg").css('display','none')

        var n = '';
        if($("#search_content").val()){//作品名称
            n=n+"作品名称："+$("#search_content").val()+";"
        }
        if($("#search_user_name").val()){//作者名字
            n=n+"作者名字："+$("#search_user_name").val()+";"
        }
        if($("#search_work_id").val()){//作品编号
            n=n+"作品编号："+$("#search_work_id").val()+";"
        }
        if($("#district_id").val()!=0){//地址
            n=n+"推荐单位："+$("#district_name").val()+";"
        }
        if(n != '') {
            $(".all_search_input").val(n)
        }
        getLastesFiveWork();

    }

    function refu(b){
        //清空作品
        $("#order_main").find(".order_work_list").empty();
        //作品名称
        $("#search_content").val('');
        $("#search_box").val('');
        //作者名字
        $("#search_user_name").val('');
        $("#search_name").val('');
        //作品编号
        $("#search_work_id").val('');
        $("#search_id").val('');
        //地址
        $("#district_id").val('');
        $("#district_name").val('');

        $(".show_search,.bg").css('display','none')
        $(".all_search_input").val('')

        getLastesFiveWork();

    }

    $("#order_main .order_work_list").on("tap", "li", function () {
        if ($(this).children("input").first().val()) {
            window.location.href = "/front/showWork?work_id=" + $(this).children("input").first().val();
        } else {
            alert("该作品暂无信息！")
        }
    })

    //关闭对话框
    function closeDialog(btn) {
        $(btn).parents(".window_parent").css("display", "none");
    }

    //关闭对话框
    function closePrize(btn) {
        $(btn).siblings("#prize_content").html("")
        $(btn).parents(".window_parent").css("display", "none");
    }

    //显示对话框详情
    function showDialog_ActivityPrizeRule() {
        var rule = JSON.parse(window.localStorage.getItem("activity")).prize_rule;
        if(rule!=='') {
            $("#activity_instruction").find(".detail_content").children("p").html(rule).css("display", "block");
            $("#activity_instruction").css("display", "block");
        }else {
            $("#activity_instruction").find(".detail_content").children("p").html("<p style=\"    margin: 0 auto 1rem;width: 50%\" >暂无获奖规则</p>").css("display", "block");
            $("#activity_instruction").css("display", "block");
        }
    }
    function showDialog_ActivityTime() {
        $("#time_instruction").css("display", "block");
    }
    function showDialog_ActivityPrizedetail() {

        var act_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;

        $.ajax({
            method: "get",
            url: "/front/getPrizes"
            , async: false//同步获取信息
            , data: {
                activity_id: act_id
            },
            dataType: "json"
            , dataFilter: function (data, type) {
                return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
            }
            , success: function (res) {
                console.log("res", res);
                if (res.data.length > 0) {
                    //实例化作品
                    for (var i = 0; i < res.data.length; i++) {
                        $("#prize_instruction").find("#prize_content").append($("#prize_item").html().replace(tplReg, function (node, key) {
                            if (key == "no") {
                                return $("#prize_instruction").find("#prize_content").children().length + 1;
                            }
                            return res.data[i][key];
                        }))
                    }
                    $("#prize_instruction").css("display", "block");
                }else{
                    $("#prize_instruction").find("#prize_content").append($("#prize_item1").html().replace(tplReg, function (node, key) {
                        return res.data[i][key];
                    }))
                    $("#prize_instruction").css("display", "block");
                }
            }
        });
    }

    //获取将名单详情
    function showWinners() {

        var act_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;

        $.ajax({
            method: "get",
            url: "/front/getPrizeWorks"
            , async: false//同步获取信息
            , data: {
                activity_id: act_id
            },
            dataType: "json"
            , dataFilter: function (data, type) {
                return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
            }
            , success: function (res) {
                console.log("res", res);
                var pt=$("#prizeWork_instruction").find("#prizeWork_content");
                if (res.data.length > 0) {

                    //实例化作品
                    for (var i = 0; i < res.data.length; i++) {
                        pt.append('<p>'+res.data[i].prize_name+'</p>');
                        if(res.data[i].worklist.length<=0){

                            pt.append($("#prizeWork_item1").html())
                            continue;
                        }
                        res.data[i].worklist.forEach(function(item,idx){
                            pt.append($("#prizeWork_item").html().replace(tplReg, function (node, key) {
                                // if (key == "no") {
                                //     return $("#prizeWork_instruction").find("#prizeWork_content").children().length + 1;
                                // }
                                return item[key];
                            }))
                        })

                    }
                    $("#prizeWork_instruction").css("display", "block");
                }else{
                    pt.append($("#prize_item1").html());
                    $("#prizeWork_instruction").css("display", "block");
                }
            }
        });





    }
    //清除 页面内容  也就是对页面进行初始化 方便后续操作
    window.clearPage = function (idx) {
        switch (idx) {
            case 1:
                //清空页面内容
                $("#activity_main").find(".act_user_info").empty();
                $("#activity_main").find(".activity_state").empty();
                $("#activity_main").find(".time_remaing").empty();
                $("#activity_main").find("#activity_details").empty();
                //添加清空标记
                $("#activity_main").addClass("has-clear");
                break;
            case 2:
                //清空内容
                $("#order_main").find(".votes_rule").empty();
                $("#order_main").find(".order_work_list").empty();
                $("#search_box").val('');
                $("#search_content").val('');
                $("#search_user_name").val('');
                $("#search_work_id").val('');





                $("#district_id").val('');
                $("#district_name").val('');
                //添加清除标记
                $("#order_main").addClass("has-clear");
                break;
            case 3:
                //清空页面内容
                $("#register_main").empty();
                $("#register_main").addClass("has-clear");
                break;
            case 4:
                $("#prize_main").addClass("has-clear");
                break;
        }
    }
    //倒计时


    //切换页面
    window.switchToPage = function (idx) {

        if(idx==3&&!isLogin())return;
        //1、从sessionStorage 中取值
        //如果是跳转页面 禁止跳转 提示选择活动
        if (!window.localStorage.getItem("activity")) {
            alert("页面错误，请先选择一个活动！")
            return;
        }
        var act_info = JSON.parse(window.localStorage.getItem("activity"));

        //console.log("act_info", act_info);
        var pic = JSON.parse(window.localStorage.getItem("activity")).activity_img  ;
        //console.log("pic",pic)
        $("#pic").css("background-image",'url('+pic+')');
        //记录当前的页面状态
        // window.currentIndex = idx;
        window.localStorage.setItem("last_index", idx);

        switch (idx) {
            case 1:
                //切换到 活动首页
                //TODO: 显示 没有则初始化
                $("#activity_main").addClass("active").siblings(".page").removeClass("active");
                if ($("#activity_main").hasClass("has-clear")) {
                    //如果有清空表记 那么 就初始化
                    //设置用户参与信息
                    $("#activity_main").find(".act_user_info").html($("#tpl_act_user_info_content").html().replace(tplReg, function (node, key) {
                        return act_info[key];
                    }))
                    //活动状态
                    $("#activity_main").find(".activity_state").html(0 == act_info.activity_state ? "未开始" : 1 == act_info.activity_state ? "进行中" : "已结束");

                    var remain = parseInt(act_info.time_remaining);//剩余时间
                    var zong =act_info.time_progress;//总时间
                    setInterval(countDown, 1000);
                    remain /= 1000;
                    if(remain<0){
                        return;
                    }
                    function countDown() {
                        if(remain>0){
                            remain=remain-1;
                        }
                        var time_remain = {
                            day: parseInt(remain / (3600 * 24)),
                            hour: parseInt(remain % (3600 * 24) / 3600),
                            minute: parseInt(remain % (3600 * 24) % 3600 / 60),
                            second: parseInt(remain % (3600 * 24) % 3600 % 60)
                        };
                        $("#activity_main").find(".time_remaing").html($("#tpl_time_remaining").html().replace(tplReg, function (node, key) {
                            return time_remain[key];
                        }))
                        if(0 == act_info.activity_state){
                            $("#activity_main").find(".progressbar_front").css("width", "0%");
                        }else if(1 == act_info.activity_state){
                            if(remain>0) {
                                if(act_info.falg == "0") {
                                    $("#activity_main").find(".progressbar_front").css("width", Math.round((zong - remain * 1000) / zong * 10000) / 100.00 + "%");
                                }else if(act_info.falg == "1"){
                                    $("#activity_main").find(".progressbar_front").css("width", "0%");
                                }else if(act_info.falg == "2"){
                                    $("#activity_main").find(".progressbar_front").css("width", "100%");
                                }
                            }else{
                                $("#activity_main").find(".progressbar_front").css("width", "100%");
                            }
                        }else if(2 == act_info.activity_state){
                            $("#activity_main").find(".progressbar_front").css("width", "100%");
                        }
                    }
                    $("#activity_main").find("#activity_details").html(act_info.activity_details);
                     //清除标记*/
                    $("#activity_main").removeClass("has-clear")
                } else {

                    //如果没有has-clear 那么可以不做任何操作
                }
                break;
            case 2:
                $("#search_box").val('');
                $("#search_content").val('');
                $("#search_user_name").val('');
                $("#search_work_id").val('');
                $("#district_id").val('');
                $("#district_name").val('');

                //切换到 排行榜页
                //TODO: 显示  清空了则初始化
                $("#order_main").addClass("active").siblings(".page").removeClass("active");
                if ($("#order_main").hasClass("has-clear")) {
                    //如果有清空表记 那么 就初始化

                    var act_info = JSON.parse(window.localStorage.getItem("activity"));
                    //2、显示加载进度条
                    //设置投票规则
                    $("#order_main").find(".votes_rule").html($("#tpl_order_work_votes_rule").html().replace(tplReg, function (node, key) {
                        return act_info[key];
                    }))
                    //获取作品信息
                    //请求网络 根据 活动 加载作品
                    $.ajax({
                        method: "get",
                        url: "/front/getWorksWithOrder"//TODO 请求排行榜作品的路径  多种排序方式 新发布 得票多 综合
                        , async: false//同步获取信息
                        , data: {
                            search_content: '',
                            order_type: 0,//0投票数 1 新发布 2 随机
                            start: 1,
                            count: 7,
                            activity_id: act_info.activity_id
                        },
                        dataType: "json"
                        , dataFilter: function (data, type) {
                            return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
                        }
                        , success: function (res) {
                            console.log("res", res);
                            //获取成功 作品列表
                            if (res.code == 0) {
                                alert("服务器返回了错误的结果！")
                                return;
                            }

                            if (res.data.length > 0) {
                                //实例化作品
                                for (var i = 0; i < res.data.length; i++) {
                                    $("#order_main").find(".order_work_list").append($("#tpl_order_work_item").html().replace(tplReg, function (node, key) {

                                        if (key == "no") {
                                            return $("#order_main").find(".order_work_list").children().length + 1;
                                        }
                                        return res.data[i][key];
                                    }))
                                }
                            } else {
                                //TODO 提示没有更多
                            }
                        }
                        , error: function (res) {
                            alert("正在加载···")
                        }, complete: function (res) {
                            //清除加载
                        }
                    });
                    $("#order_main").removeClass("has-clear")
                } else {

                    //如果没有has-clear 那么可以不做任何操作
                }
                break;
            case 3:
                var user_info = JSON.parse(window.localStorage.getItem("user_info"));
                var signup = JSON.parse(window.localStorage.getItem("activity")).is_sigup;
                var winner = $("#winner").val();
                //切换到 报名信息页面
                //TODO: 显示 没有则初始化
                //请求用户报名信息
                $("#register_main").addClass("active").siblings(".page").removeClass("active");
                if ($("#register_main").hasClass("has-clear")) {

                    $.ajax({
                        url: "/front/getRegInfoAndWorkInfo",
                        method: "get",
                        data: {
                            activity_id: act_info.activity_id,
                            user_id: user_info.user_id
                        },
                        dataType: "json",
                        async: false,
                        dataFilter: function (data, type) {
                            return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
                        },
                        success: function (res) {
                            if(signup==1){//报名结束
                                if(winner == 1){//显示获奖
                                    if (res.code == 1) {
                                        if (res.reg_info) {
                                            if (res.work_info && res.work_info.length > 0) {
                                                //显示第三个 报名信息 和 作品信息都有
                                                var up = $($("#state_all_infono").html().replace(tplReg, function (node, key) {
                                                    return res.reg_info[key];
                                                }));
                                                for (var i = 0; i < res.work_info.length; i++) {
                                                    var work_item = res.work_info[i];
                                                    var item;
                                                    if (work_item.work_type == 0) {
                                                        item = $("#my_work_item_vno").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    } else if (work_item.work_type == 1) {
                                                        item = $("#my_work_item_ano").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    } else if (work_item.work_type == 2) {
                                                        item = $("#my_work_item_pno").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    }
                                                    up.find(".works_content").append(item);
                                                }
                                                if(act_info.works_limit_peruser<=res.work_info.length){
                                                    up.find(".works_details_2").css("display","none");
                                                }
                                                $("#register_main").html(up.prop("outerHTML"));
                                            } else {
                                                //无作品 显示第二个
                                                $("#register_main").html($("#state_no_work_infono").html().replace(tplReg, function (node, key) {
                                                    return res.reg_info[key];
                                                }));
                                            }
                                        } else {
                                            $("#register_main").html($("#state_no_all_infono").html());
                                            //显示 第一个  无报名信息
                                        }
                                    } else {
                                        alert("查询失败！")
                                    }
                                }else{
                                    if (res.code == 1) {
                                        if (res.reg_info) {
                                            if (res.work_info && res.work_info.length > 0) {
                                                //显示第三个 报名信息 和 作品信息都有
                                                var up = $($("#state_all_infono").html().replace(tplReg, function (node, key) {
                                                    return res.reg_info[key];
                                                }));
                                                for (var i = 0; i < res.work_info.length; i++) {
                                                    var work_item = res.work_info[i];
                                                    var item;
                                                    if (work_item.work_type == 0) {
                                                        item = $("#my_work_item_vnoy").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    } else if (work_item.work_type == 1) {
                                                        item = $("#my_work_item_anoy").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    } else if (work_item.work_type == 2) {
                                                        item = $("#my_work_item_pnoy").html().replace(tplReg, function (node, key) {
                                                            return work_item[key];
                                                        });
                                                    }
                                                    up.find(".works_content").append(item);
                                                }
                                                if(act_info.works_limit_peruser<=res.work_info.length){
                                                    up.find(".works_details_2").css("display","none");
                                                }
                                                $("#register_main").html(up.prop("outerHTML"));
                                            } else {
                                                //无作品 显示第二个
                                                $("#register_main").html($("#state_no_work_infono").html().replace(tplReg, function (node, key) {
                                                    return res.reg_info[key];
                                                }));
                                            }
                                        } else {
                                            $("#register_main").html($("#state_no_all_infono").html());
                                            //显示 第一个  无报名信息
                                        }
                                    } else {
                                        alert("查询失败！")
                                    }
                                }
                            }else{
                                if (res.code == 1) {
                                    if (res.reg_info) {
                                        if (res.work_info && res.work_info.length > 0) {
                                            //显示第三个 报名信息 和 作品信息都有
                                            var up = $($("#state_all_info").html().replace(tplReg, function (node, key) {
                                                return res.reg_info[key];
                                            }));
                                            for (var i = 0; i < res.work_info.length; i++) {
                                                var work_item = res.work_info[i];
                                                console.log("单个作品：", work_item);
                                                var item;
                                                if (work_item.work_type == 0) {
                                                    item = $("#my_work_item_v").html().replace(tplReg, function (node, key) {
                                                        return work_item[key];
                                                    });
                                                } else if (work_item.work_type == 1) {
                                                    item = $("#my_work_item_a").html().replace(tplReg, function (node, key) {
                                                        return work_item[key];
                                                    });
                                                } else if (work_item.work_type == 2) {
                                                    item = $("#my_work_item_p").html().replace(tplReg, function (node, key) {
                                                        return work_item[key];
                                                    });
                                                }
                                                up.find(".works_content").append(item);
                                            }
                                            if(act_info.works_limit_peruser<=res.work_info.length){
                                                up.find(".works_details_2").css("display","none");
                                            }
                                            $("#register_main").html(up.prop("outerHTML"));
                                        } else {
                                            //无作品 显示第二个
                                            $("#register_main").html($("#state_no_work_info").html().replace(tplReg, function (node, key) {
                                                return res.reg_info[key];
                                            }));
                                        }
                                    } else {
                                        $("#register_main").html($("#state_no_all_info").html());
                                        //显示 第一个  无报名信息
                                    }
                                } else {
                                    alert("查询失败！")
                                }
                            }
                        },
                        error: function (res) {
                            alert("正在加载···")
                        }
                    })
                    $("#register_main").removeClass("has-clear")
                } else {

                }
                break;
            case 4:
                //切换到 奖项页面
                //记录当前的页面状态
                $("#prize_main").addClass("active").siblings(".page").removeClass("active");
                if ($("#prize_main").hasClass("has-clear")) {
                    $("#prize_main").removeClass("has-clear")
                } else {
                    //不做任何操作
                }
                break;
        }
    }
    window.IsArray = function (v) {
        return Object.prototype.toString.call(v) == '[object Array]';
    }
    window.IsObject = function (v) {
        return Object.prototype.toString.call(v) == '[object Object]';
    }

    window.getLowerCaseKeyJsonByRecursive = function (obj) {
        var ret = {}//转成对象 进行属性名小写化
        if (window.IsArray(obj)) {
            console.log("array");
            ret = [];
            for (var i = 0; i < obj.length; i++) {
                //此方法一定可以完成 这个功能 传入一个大写KEY 导出一个小写KEY
                var tmp_obj = window.getLowerCaseKeyJsonByRecursive(obj[i])
                ret.push(tmp_obj);
            }
            return ret;
        } else if (window.IsObject(obj)) {
            console.log("object");
            ret = {};
            for (var key in obj) {
                //普通字符串
                ret[key.toLowerCase()] = window.getLowerCaseKeyJsonByRecursive(obj[key]);
            }
            return ret;
        } else {
            return obj;
        }
    }
    window.WechatAuthToGetUserInfo = function () {
        console.log("用户授权");
        var admin = $("#admin").val();
        //var addr="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1395f72209d8ddf4&redirect_uri=http%3A%2F%2Ftp.cqst.org.cn%2Ffront%2FwxCallBack&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        console.log("登录前活动信息：",window.localStorage.getItem("activity"));
        console.log("admin：",admin);
        window.location.href = "/front/userLogin?state=%2ffront%2finitUserInfo%3factivity_id%3d"+JSON.parse(window.localStorage.getItem("activity")).activity_id+"%3d"+admin;
    }

    //序列化表单
    $.fn.serializeObject = function () {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function () {
            if (o[this.name]) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    }
    //初始化的地方
    // $(function () {
    //所有的活动信息
    var activity = {
        activity_id: 0,
        activity_name: '',
        activity_img: '',
        activity_details: '',
        activity_starttime: '',
        activity_endtime: '',
        activity_win: 0,
        stage_is_open: '',
        stage_1st_name: '',
        stage_1st_endtime: '',
        stage_1st_win: 0,
        stage_2nd_name: '',
        stage_2nd_endtime: '',
        stage_2nd_win: 0,
        stage_3rd_name: '',
        stage_3rd_endtime: '',
        stage_3rd_win: 0,
        stage_4th_name: '',
        stage_4th_endtime: '',
        stage_4th_win: 0,
        activity_state: '',//0 未开始 1 进行中  2已结束
        activity_visit: '',
        votes_user: 0,
        votes_number: 0,
        votes_limit_perday: 0,
        votes_limit_tosingle_perday: 0,
        prize_rule: '',
        create_time: '',
        work_type:0,
        is_vote:0,
        prize_name: '',
        user_name: '',
        work_imgurl: '',
        work_name: ''
    }
    //判断是否有活动信息
    //console.log("初始化活动信息：",window.localStorage.getItem("activity"));
    if (window.localStorage.getItem("activity")) {//活动里面右值
        //进入活动首页
        //显示活动页 获取活动id 网络请求 并获取新的信息
        var act_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
        //console.log("检测到活动ID: ",act_id);
        //1、隐藏更多活动界面
        $("#act_list_main").css("display", "none").css("left", "-100vw");
        setTimeout(function () {
            $("#act_list_main").css("display", "block")
        }, 500)
        window.showLoading();
        //2、向服务器请求活动的详细信息
        $.ajax({
            method: "get",
            url: "/front/getActivityInfoById"
            , async: true
            , dataType: "json"
            , data: {
                activity_id: act_id
            }
            ,
            dataFilter: function (data, type) {
                return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
            },
            success: function (res) {
                //console.log(res);
                //将活动信息 存储到本地
                if (res.code == 1) {
                    document.title = res.data.activity_name;//活动名称
                    //本地持久化
                    window.localStorage.setItem("activity", JSON.stringify(res.data))
                    var index=localStorage.last_index?parseInt(localStorage.last_index):1;
                    console.log("index:..........",index);
                    if(index==3){
                        window.clearPage(3);
                    }
                    setTimeout(function(){
                        window.changeFooterButton(index);
                        window.switchToPage(index);
                    },20)
                } else {
                    alert("服务器返回了错误的结果！")
                }
            },
            error: function (res) {
                alert("正在加载···")
            },
            complete:function(res){
                window.closeLoading();
            }
        })
    } else {
        //默认就是显示活动列表页面
        //点击活动 需要获取用户信息  此时获取用户信息
        document.title = "热门活动";
        //请求五个活动
        getLastestFiveActivity();
    }
    //更多活动的点击事件
    $("#more_act").on("tap", function () {
        //显示活动列表
        $("#act_list_main").css("left", "0");
        //显示返回按钮
        setTimeout(function () {
            //动画结束时 显示返回图标 更换标题
            $("#more_act_hide").css("display", "inline-block");
            document.title = "热门活动";
        }, 500)
        //临时记录 title
        window.localStorage.setItem("last_title", document.title);
        //如果活动下面的数据为空 那么就请求网络
        //获取最近五个活动
        if ($("#act_list_main").find("ul>li.content_activity_item").length <= 0) {
            //如果列表中没有数据 那么每次都去服务器查询
            getLastestFiveActivity();
        }
    })
    //活动界面的上拉加载更多
    $("#act_list_main").off("scroll").on("scroll", function () {
        //获取当前浏览器的滚动条高度
        //scrollHeight真实高度
        if (this.scrollHeight <= (this.scrollTop + $(this).height())) { //判断当前浏览器滚动条高度是否已到达浏览器底部，如果到达底部加载下一页数据信息
            // $("#loadingImg").css('visibility','visible');
            console.log("滑到底部 。。。");
            //加载更多
            $(this).children().last().removeClass("hasnomore").addClass("loading");
            getLastestFiveActivity();
        }
    });
    $("#order_main .content").off("scroll").on("scroll", function () {
        //获取当前浏览器的滚动条高度
        //scrollHeight真实高度
        if (this.scrollHeight <= (this.scrollTop + $(this).height()+10)) { //判断当前浏览器滚动条高度是否已到达浏览器底部，如果到达底部加载下一页数据信息
            // $("#loadingImg").css('visibility','visible');
            console.log("滑到底部 。。。");
            //加载更多
            $(this).children().last().removeClass("hasnomore").addClass("loading");
            getLastesFiveWork();
        }
    })
    var loadMoreWorks = false;

    //获取最新的五个作品
    function getLastesFiveWork() {
        if (loadMoreWorks) {
            return;
        }
        loadMoreWorks = true;
        var activity_id = JSON.parse(window.localStorage.getItem("activity")).activity_id;
        console.log("类型:", typeof activity_id)
        $.ajax({
            method: "get",
            url: "/front/getWorksWithOrder"//TODO 请求排行榜作品的路径  多种排序方式 新发布 得票多 综合
            , async: true//同步获取信息
            , data: {
                search_content: $("#search_content").val(),//
                search_user_name:$("#search_user_name").val(),
                search_work_id:$("#search_work_id").val(),
                district_id:$("#district_id").val(),
                order_type: 0,//0投票数 1 新发布 2 随机
                start: $("#order_main .order_work_list").children("li").length + 1,
                count: 7,
                activity_id: activity_id
            },
            dataType: "json"
            , dataFilter: function (data, type) {
                return JSON.stringify(window.getLowerCaseKeyJsonByRecursive(JSON.parse(data)));
            }
            , success: function (res) {
                console.log("res", res);
                //获取成功 作品列表
                if (res.code == 0) {
                    alert("服务器返回了错误的结果！")
                    return;
                }
                if (res.data.length > 0) {
                    //实例化作品
                    for (var i = 0; i < res.data.length; i++) {
                        $("#order_main").find(".order_work_list").append($("#tpl_order_work_item").html().replace(tplReg, function (node, key) {

                            if (key == "no") {
                                return $("#order_main").find(".order_work_list").children().length + 1;
                            }
                            return res.data[i][key];
                        }))
                    }
                    $("#order_main .content").children().last().removeClass("loading").removeClass("hasnomore");

                } else {
                    $("#order_main .content").children().last().removeClass("loading").addClass("hasnomore");

                    //TODO 提示没有更多
                }
            }
            , error: function (res) {
                alert("正在加载···")
            }, complete: function (res) {
                //清除加载
                loadMoreWorks = false;
            }
        });
    }

    var loadMoreActivity = false;

    //获取最近的五个作品
    function getLastestFiveActivity() {
        if (loadMoreActivity) {
            return;
        }
        loadMoreActivity = true;
        //第一次请求 以及上拉加载时都要调用该方法
        var count = $("#act_list_main").find("ul>li.content_activity_item").length;
        var admin = $("#admin").val();
        //已经加载的活动的数量
        $.ajax({
            method: 'get',
            url: "/front/getActivities"//TODO:请求获取 活动列表的地址
            , async: true
            , data: {
                start: count + 1,//从多少开始
                count: 5,         //请求多少个
                admin: admin
            }
            , dataType: "json"
            , dataFilter: function (data, type) {
                var retobj = window.getLowerCaseKeyJsonByRecursive(JSON.parse(data))

                var ret = JSON.stringify(retobj);
                return ret;
            }
            , success: function (res) {
                if (res.code == 0) {
                    alert("服务器返回了的错误的信息！")
                    return;
                }
                if (res.data.length > 0) {
                    //TODO：实例化到页面上
                    for (var i = 0; i < res.data.length; i++) {

                        if(res.data[i].is_rote == 0) {//设置投票
                            var one = res.data[i];
                            var item = $($("#tpl_activity_item").html().replace(tplReg,
                                function (node, key) {
                                    if (key == "activity_state") {
                                        return one[key] == "0" ? "<span class='nostart'>未开始</span>" : one[key] == "1" ? "<span class='ing'>进行中</span>" : "<span class='end'>已结束</span>";
                                    }
                                    return one[key];
                                }
                            ));
                            var stage_time_obj = {};
                            stage_time_obj = {
                                stage_name: "时间",
                                stage_start_time: one.activity_starttime.split(' ')[0],
                                stage_end_time: one.activity_endtime.split(' ')[0]
                            };
                            item.find(".activity_stage_info").append($("#tpl_activity_stage_item").html().replace(tplReg, function (node, key) {
                                return stage_time_obj[key];
                            }))
                            // }
                            $("#act_list_main").find("ul").append(item);
                        }else{
                            var one = res.data[i];
                            var item = $($("#tpl_activity_items").html().replace(tplReg,
                                function (node, key) {
                                    if (key == "activity_state") {
                                        return one[key] == "0" ? "<span class='nostart'>未开始</span>" : one[key] == "1" ? "<span class='ing'>进行中</span>" : "<span class='end'>已结束</span>";
                                    }
                                    return one[key];
                                }
                            ));
                            var stage_time_obj = {};
                            stage_time_obj = {
                                stage_name: "时间",
                                stage_start_time: one.activity_starttime.split(' ')[0],
                                stage_end_time: one.activity_endtime.split(' ')[0]
                            };
                            item.find(".activity_stage_info").append($("#tpl_activity_stage_item").html().replace(tplReg, function (node, key) {
                                return stage_time_obj[key];
                            }))
                            // }
                            $("#act_list_main").find("ul").append(item);
                        }
                    }
                    $("#act_list_main").children().last().removeClass("hasnomore").removeClass("loading");
                } else {
                    //TODO:提示没有 更多
                    $("#act_list_main").children().last().removeClass("loading").addClass("hasnomore");
                }
            },
            error: function (res, b) {
                alert("正在加载···")
            }, complete: function (res) {
                loadMoreActivity = false;
            }
        })
    }

    // 退出 更多活动 ======================================================================================
    $("#more_act_hide").on('tap', function () {
        //隐藏按钮
        $(this).css("display", "none");
        //退出活动列表显示
        $("#act_list_main").css("left", "-100vw")
        setTimeout(function () {
            //还原标题 动画结束后
            document.title = window.localStorage.getItem("last_title");
        }, 500);
    })
    //给每个活动添加点击事件 并切换到该活动的界面下面
    $("#act_list_main").on("tap", "ul>li.content_activity_item", function () {
        window.localStorage.setItem("last_index",1);
        var that=this;
        var admin = $("#admin").val();
        setTimeout(function () {
            //找到
            var id = $(that).find("input").val();
            var ins = $(that).find("input").next().val();
            //console.log($(this).find("input").val())
            if(ins==0) {
                window.location.replace("/front/activity?activity_id="+id+"&admin="+admin);
            } else {
                alert("该活动评审已结束！");
                window.closeLoading();
            }
        },20);
    })

    //切换到对应的活动
    function switchToActivity() {
        if (!window.localStorage.getItem("activity")) {
            alert("打开活动时没有检测到相应的活动标识！")
            return;
        }
        //应该把所有的数据都删了 然后重新加载一遍
        window.clearPage(1);
        window.clearPage(2);
        window.clearPage(3);
        window.clearPage(4);
        //这里应该切换到活动首页
        window.changeFooterButton(1);
        window.switchToPage(1);

        //退出活动列表显示
        $("#act_list_main").css("left", "-100vw")

        $("#more_act_hide").css("display", "none");

        //还原标题 动画结束后
        document.title = JSON.parse(window.localStorage.getItem("activity")).activity_name;

        //出现加载条 更新数据
    }


    $("#activity_main").find(".iwannaregiste").click(function () {
        window.changeFooterButton(3);
        window.switchToPage(3)
    })
    $("#activity_main").find(".iwannavote").click(function () {
        window.changeFooterButton(2);
        window.switchToPage(2)
    })
    window.changeFooterButton = function (idx) {

        var that = $("#footer").find("li:nth-child(" + idx + ")")[0];

        $(that).addClass("active").siblings().removeClass("active");

        $(that).find("img").attr("src", $(that).find("img").attr("data-selected_url"));

        var allimgs = $(that).siblings();

        allimgs.each(function (index, item) {

            $(item).find("img").attr("src", $(item).find("img").attr("data-normal_url"));
        })

    }
    //底部tab栏的事件
    $("#footer").find("li").on("tap", function () {

        if (!window.localStorage.getItem("activity")) {
            alert("页面错误，请先选择一个活动！")
            return;
        }
        var idx = parseInt($(this).children("a").attr("data-page_id"));
        window.changeFooterButton(idx);
        window.switchToPage(idx)
    })

    $("#button_signup").on("tap", function () {
        $(".succeed").css("display", "block")
    })
    $("#confirm").on("tap", function () {
        $(".succeed").css("display", "none")
    })
    $("#quit").on("tap", function () {
        $(".video_win_mask").css("display", "none")
    })
    $("#audio_btn").on("tap", function () {
        $(".audio1").css("display", "block")
    })
    $("#video_btn").on("tap", function () {
        $(".video_win_mask").css("display", "block")
    })
//    搜索
    $(".all_search_input").click(function(){
        $(".show_search,.bg").css('display','block')
    })
//    取消
    $(".cancel").click(function(){
        $(".show_search,.bg").css('display','none')
    })
</script>

</body>
</html>
